<ul>
	<?php foreach ($types as $type): ?>
			<li><?php echo CHtml::checkBox('_'.$type['name'], false); ?><?php echo $type['name'] ?></li>
	<?php endforeach ?>
	<script type="text/javascript" charset="utf-8">
	$(function($) {
		$('li input:checkbox').each(function(){
			$(this).change(function(){
				$('#div'+$(this).attr('name')).css('display',($(this).is(':checked')?'block':'none'));
			});
		});
	});
</script>
</ul>
<?php if (!Yii::app()->user->isGuest && $store['name']==Yii::app()->user->store_name): ?>
<div id="New">
	<h3>Nuevo</h3>
	<div id="new" class="product">
		<a href="<?php echo $this->createUrl('product/add', array('store_id'=>$store['id'])) ?>" rel="facebox" class="item">
			<img src="images/add.png" />
			<h4>Nuevo</h4>
			<p>Agregar Producto</p>
		</a>	
	</div>
	<div id="new" class="product">
		<a href="<?php echo $this->createUrl('post/add', array('store_id'=>$store['id'])) ?>" rel="facebox" class="item">
			<img src="images/add.png" />
			<h4>Nuevo</h4>
			<p>Escribir Post</p>
		</a>	
	</div>
	<div class="clear"></div>
</div>
<?php endif ?>
<?php $type = '_uno'; ?>
<?php foreach ($products as $product): ?>
	<?php if ($type!=$product['tname']): ?>
		<?php if ($type!='_uno'): ?>			
			<div class="clear"></div>
			</div>
		<?php endif ?>
		<script type="text/javascript" charset="utf-8">
			$(function($) {
				$('#_<?php echo $product['tname'] ?>').attr('checked','checked');
			});
		</script>
		<div id="div_<?php echo $product['tname'] ?>">
		<h3><?php echo $product['tname'] ?></h3>
	<?php endif ?>
	
	<div id="<?php echo $product['pid'] ?>" class="product">
		<a href="<?php echo $this->createUrl('product/index', array('id'=>$product['pid'])) ?>" rel="facebox" class="item">
			<img src="images/products/<?php echo $product['pid'] ?>/<?php echo $product['url_80'] ?>" />
			<h4><?php echo $product['pname'] ?></h4>
			<p>Desde <?php echo $product['price_from'] ?></p>
		</a>
		<?php if (!Yii::app()->user->isGuest && $store['name']==Yii::app()->user->store_name): ?>
			<div id="a<?php echo $product['pid'] ?>" style="display:none" class="edit">
				<a id="def<?php echo $product['pid'] ?>" href="#"><img src="images/ok.png" title="Mostrar en la Vitrina"/></a>
				<a href="<?php echo $this->createUrl('product/edit', array('id'=>$product['pid'])) ?>" rel="facebox"><img src="images/edit.png" title="Editar Producto"/></a>	
				<a id="rem<?php echo $product['pid'] ?>" href="#"><img src="images/delete.png" title="Eliminar Producto"/></a>
			</div>
			<script type="text/javascript" charset="utf-8">
				$('#def<?php echo $product['pid'] ?>').click(function(){
						$.get('<?php echo $this->createUrl('product/default', array('store_id'=>$store['id'], 'id'=>$product['pid'])) ?>', function(data){
							alert(data);
						});
					});
				$('#rem<?php echo $product['pid'] ?>').click(function(){
						$.get('<?php echo $this->createUrl('product/delete', array('id'=>$product['pid'])) ?>', function(data){
							$('#<?php echo $product['pid'] ?>').fadeOut(500);
						});
					});
				$('#<?php echo $product['pid'] ?>').hover(
					function(){
						$('#a<?php echo $product['pid'] ?>').fadeIn(100);
					},
					function(){
						$('#a<?php echo $product['pid'] ?>').fadeOut(100);
					});
			</script>
		<?php endif ?>
	</div>
	<?php $type = $product['tname']; ?>
<?php endforeach ?>
</div>
<div class="clear"></div>
<script type="text/javascript" charset="utf-8">
	$(document).ready(function(){
		$('#key').focus();
		$('a[rel*=facebox]').facebox();
	});
</script>